﻿using System.Net.Http.Json;
using SMCL.Core.Utils.Static;
using SMCL.Core.Utils.Types.Json;

namespace SMCL.Core.Utils.Game
{
    public partial class Versions
    {
        public async Task<Types.Versions> GetVersions()
        {
            var client = new HttpClient();
            client.DefaultRequestHeaders.UserAgent.Add(new(Launcher.Brand, "0.0.1"));
            client.DefaultRequestHeaders.UserAgent.Add(new("Microsoft.NET", Environment.Version.ToString()));
            var response = await client.GetAsync("https://bmclapi2.bangbang93.com/mc/game/version_manifest.json");
            var versionMainfest = await response.Content.ReadFromJsonAsync<VersionManifest>();
            return new Types.Versions(versionMainfest);
        }
    }
}
